package com.example.demo;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Test;

import java.io.File;
import java.io.IOException;

public class test_jaclk {

    @Test
    public void test1() throws IOException {
        Person p=new Person();
        p.setAge(20);
        p.setName("wang");
        ObjectMapper mapper=new ObjectMapper();
        //writeValue
        String json=mapper.writeValueAsString(p);
        System.out.println(json);
        mapper.writeValue(new File("d://a.txt"),p);
    }
}
class Person{
    String name;
    int age;



    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}
